package com.woniuxy.woniuhis.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.woniuhis.entity.SurgeryConfirm;
import com.woniuxy.woniuhis.exception.SurgeryConfirmServiceException;
import com.woniuxy.woniuhis.mapper.SurgeryConfirmMapper;
import com.woniuxy.woniuhis.service.SurgeryConfirmService;

@Service
public class SurgeryConfirmServiceImpl implements SurgeryConfirmService {

	@Autowired
	SurgeryConfirmMapper surgeryConfirmMapper;

	/**
	 * 添加手术同意书
	 */
	@Override
	public void addSurgeryConfirm(SurgeryConfirm surgeryConfirm) {
		try {
			surgeryConfirmMapper.insertSurgeryConfirm(surgeryConfirm);
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}
	}

	/**
	 * 更新手术同意书
	 */
	@Override
	public void modifySurgeryConfirm(SurgeryConfirm surgeryConfirm) {
		try {
			surgeryConfirmMapper.updateSurgeryConfirm(surgeryConfirm);
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}
	}

	/**
	 * 按主键查询指定手术同意书
	 */
	@Override
	public SurgeryConfirm findSurgeryConfirmById(String id) {
		try {
			return surgeryConfirmMapper.selectSurgeryConfirmById(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}
	}

	/**
	 * 查询指定手术id的手术同意书
	 */
	@Override
	public SurgeryConfirm findSurgeryConfirmsBySurgeryExeId(String surgeryExeId) {
		try {
			SurgeryConfirm surgeryConfirm = surgeryConfirmMapper.selectSurgeryConfirmsBySurgeryExeId(surgeryExeId);
			return surgeryConfirm;
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}

	}

	/**
	 * 查询所有的手术同意书
	 */
	@Override
	public PageInfo<SurgeryConfirm> findSurgeryConfirms(int pageIndex, int pageSize) {
		try {
			PageHelper.startPage(pageIndex, pageSize);
			List<SurgeryConfirm> surgeryConfirms = surgeryConfirmMapper.selectSurgeryConfirms();
			PageInfo<SurgeryConfirm> pageinfo = new PageInfo<SurgeryConfirm>(surgeryConfirms);
			return pageinfo;
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}

	}

	/**
	 * 删除指定手术同意书
	 */
	@Override
	public void deleteSurgeryConfirmById(String id) {
		try {
			surgeryConfirmMapper.deleteSurgeryConfirmById(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw new SurgeryConfirmServiceException("系统维护中");
		}
	}

}
